package com.citcc.business.service;

import com.citcc.business.bean.CdzChargeInfo;
import com.citcc.business.bean.UserOrderEntity;
import com.citcc.business.bean.vo.StatisticsStakeVo;
import com.citcc.business.bean.vo.StatisticsStationVo;
import com.citcc.business.mapper.UserOrderEntityMapper;
import com.citcc.common.utils.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class UserOrderEntityService {


    private final UserOrderEntityMapper userOrderEntityMapper;

    @Autowired
    public UserOrderEntityService(UserOrderEntityMapper userOrderEntityMapper){
        this.userOrderEntityMapper=userOrderEntityMapper;
    }

    /**
     * 查询订单列表
     */
    public List<UserOrderEntity> queryByList(UserOrderEntity userOrderEntity){
        return userOrderEntityMapper.queryByList(userOrderEntity);
    }

    /**
     * 根据桩号统计数据
     */
    public List<StatisticsStakeVo> getStakeList(String beginTime, String endTime, String stationCodes,String orgId){
        if (StringUtils.isNotEmpty(stationCodes)){
            return userOrderEntityMapper.getStakeList(beginTime, endTime, stationCodes.split(","),orgId);
        }else {
            return userOrderEntityMapper.getStakeList(beginTime, endTime, null,orgId);
        }
    }

    /**
     * 根据站号统计数据
     */
    public List<StatisticsStationVo> getStationList(String beginTime, String endTime, String stationCodes,String orgId){
        if (StringUtils.isNotEmpty(stationCodes)){
            return userOrderEntityMapper.getStationList(beginTime, endTime, stationCodes.split(","),orgId);
        }else {
            return userOrderEntityMapper.getStationList(beginTime, endTime, null,orgId);
        }
    }

    /**
     * 根据桩号查询明细数据
     */
    public List<UserOrderEntity> getStakeDetail(UserOrderEntity userOrderEntity){
        return userOrderEntityMapper.getStakeDetail(userOrderEntity);
    }

    /**
     * 充电记录
     */
   public List<CdzChargeInfo> getAllChargeInfo(CdzChargeInfo cdzChargeInfo){
       return userOrderEntityMapper.getAllChargeInfo(cdzChargeInfo);
   }

    /**
     * 查询充电统计
     */
    public Map<String, Object> selectSumCharge(){
        return userOrderEntityMapper.selectSumCharge();
    }

}
